<?php

require_once 'Zend/View/Helper/Abstract.php';

class Core_View_Helper_General_RenderAlert extends Zend_View_Helper_Abstract
{
    /**
     * comments
     */
    public function renderAlert()
    {
        $m       = new Core_View_Message();
        $ve      = new Core_View_Error();
        $alert   = false;
        $message = null;
        $verror  = null;

        $alert = null;

        if ($ve->hasErrors()) {
            $verror = '<p>'. $this->view->getTranslation('The following errors have occurred') . ':</p>' . $this->view->htmlList($ve->get());
            $alert .= '<fieldset class="warning"><legend>'. $this->view->getTranslation('Errors') . '</legend>' . $verror . '</fieldset>';
        }

        if ($m->hasMessage()) {
            $message .= '<p>' . $m->get() . '</p>';
            $alert   .= '<fieldset class="note"><legend>'. $this->view->getTranslation('Message') . '</legend>' . $message . '</fieldset>';
        }

        //after this renders it clears the errors and messages
        $m->clear();
        $ve->clear();

        return $alert;
    }
}